import React, {PureComponent} from "react";
import {connect} from "react-redux";
import {Button, Icon, notification} from "antd";

class Toolbar extends PureComponent {
    handleExport = () => {
        document.getElementById("export").submit();
        notification.success({
            message: '请等待文件导出'
        });
    };

    render() {
        const {filter = {}} = this.props;
        return (
            <div className="actions">
                <Button style={{marginLeft: "10px"}} onClick={this.handleExport}><Icon type="export"/>导 出</Button>
                <form
                    id="export"
                    method="post"
                    target="_blank"
                    action="/api/orderAnalysis/userOperationExport"
                >
                    <input
                        name="createDateStart"
                        type="hidden"
                        value={filter.createDateStart}
                    />
                    <input
                        name="createDateEnd"
                        type="hidden"
                        value={filter.createDateEnd}
                    />
                </form>
            </div>
        );
    }
}

const mapStateToProps = state => {
    return {
        ...state.userOperation.list
    };
};

export default connect(mapStateToProps)(Toolbar);
